<?php
/*
+-----------------------------------------------------------------------------+
| $Id: *.php,v 1.* 2005/07/01 06:15:08 Bleakwind Exp $
| SnowStats
|         --- A Web Statistics Analysis for multiuser
| Copyright (c) 2003-2005 Weaverdream.com By Bleakwind
| http://www.weaverdream.com
+-----------------------------------------------------------------------------+
*/

include_once 'include/include.php';
include_once 'include/header.php';
?>

<table width="760" border="0" cellpadding="0" cellspacing="0" bgcolor="#5E94DD" align="center">
  <tr bgcolor="#5E94DD">
    <td width="200" align="center" valign="top" class="left_bg">
      <?include_once 'include/menu.php';?>
	</td>
	<td width="560" bgcolor="#FFFFFF" valign="top">

<?php
if(empty($_GET['act'])){

if(if_adminlogin() == "y"){
?>
<table width="100%" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#EBE9ED"><tr><td><img src="images/arrowright.gif" border=0 align="absmiddle"> <a href="index.php" target="_self"><font style="color:#000000;"><?php echo CONFIG_WEBSITE;?></font></a> &raquo; <?php echo $LANGUAGE['admin_login_place'];?></td></tr></table>
<br>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#5E94DD">
  <tr bgcolor="#EBE9ED">
    <td height="60" align="center">
      <?php echo sprintf($LANGUAGE['admin_login_welcome'],"<span class=\"salient\">".$_SESSION['sess_adminuser']."</span>");?>
    </td>
  </tr>
</table>
<br>
<?php
}else{
   header("location:admin_login.php?act=login");
}

}else{

switch($_GET['act']){
case "login":
?>
<table width="100%" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#EBE9ED"><tr><td><img src="images/arrowright.gif" border=0 align="absmiddle"> <a href="index.php" target="_self"><font style="color:#000000;"><?php echo CONFIG_WEBSITE;?></font></a> &raquo; <?php echo $LANGUAGE['admin_login_placedir'];?> &raquo; <?php echo $LANGUAGE['admin_login_place'];?></td></tr></table>
<br>
<table width="300" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#FFFFFF">
<form action="admin_login.php?act=savelogin" method="post">
<tr bgcolor="#5E94DD"><td align="center" class="right_title"><?php echo $LANGUAGE['admin_login_login_title'];?></td></tr>
<tr bgcolor="#EBE9ED"><td height="25" align="center"><?php echo $LANGUAGE['admin_login_adminuser'];?><input name="adminuser" type="text" size="15" maxlength="60" class="input"></td></tr>
<tr bgcolor="#EBE9ED"><td height="25" align="center"><?php echo $LANGUAGE['admin_login_adminpass'];?><input name="adminpass" type="password" size="15" maxlength="60" class="input"></td></tr>
<tr bgcolor="#5E94DD"><td height="25" align="center"><input type="submit" value="<?php echo $LANGUAGE['admin_login_submit'];?>" class="submit"> <input type="reset" value="<?php echo $LANGUAGE['admin_login_reset'];?>" class="submit">
</td></tr></form></table>
<?php
break;
case "savelogin":

if(!isset($_POST['adminuser']) || $_POST['adminuser'] == "" || !isset($_POST['adminpass']) || $_POST['adminpass'] == ""){
   header("location:prompt.php?act=failed&mes=".htmlentities(urlencode($LANGUAGE['admin_login_warning_empty'])));
   exit;
}
$adminuser    = check_username($_POST['adminuser']);
$adminpass    = check_password($_POST['adminpass']);
include "config.php";
if((CONFIG_ADMINUSERNAME != $adminuser) || (CONFIG_ADMINPASSWORD != str_encrypt($adminpass))){
   header("location:prompt.php?act=failed&mes=".htmlentities(urlencode($LANGUAGE['admin_login_warning_current_password_error'])));
   exit;
}else{
   $_SESSION['sess_adminuser'] = $adminuser;
   $_SESSION['sess_adminpass'] = $adminpass;
   header("location:prompt.php?act=succeed&url=admin_login.php&mes=".htmlentities(urlencode(sprintf($LANGUAGE['admin_login_succeed'],"<font class=\"salient\">".$_SESSION['sess_adminuser']."</font>"))));
   exit;
}

break;
case "logout":

unset($_SESSION['sess_adminuser']);
unset($_SESSION['sess_adminpass']);
header("location:prompt.php?act=succeed&url=index.php&mes=".htmlentities(urlencode($LANGUAGE['admin_login_exit_succeed'])));
exit;

break;

default:
  header("location:prompt.php");
break;

}//swich
}//empty

echo "<br></td></tr></table>";
include_once 'include/footer.php';
?>